<script src="https://7072-prd-ffx26-1255301037.tcb.qcloud.la/321zou.com/dsl/jquery/jquery-3.5.1.min.js">
</script>

<link href="/static/icon/av.svg" rel="icon" type="image/x-icon">

<script src="/depend/zTree_v3/js/jquery.ztree.core.min.js"></script>
<link href="/depend/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="/depend/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/depend/easyui/themes/icon.css">
<script type="text/javascript" src="/depend/easyui/jquery.easyui.min.js"></script>

<link href="res/index.css" rel="stylesheet" type="text/css" />
<div id="main">
    <div id="top" class="top">
        <div class="my-menu">
            <h3 style="text-align: center;">AviatorScript IDE (5.3.0-0.2.0)</h3>
        </div>
        <div class="my-tips">
        </div>
    </div>
    <div id="main-layout" class="easyui-layout" style="width:100%; height:99.5%;overflow: auto;">
        <div data-options="region:'west',split:true,title:'',collapsible:false" style="width:190px;height: auto;">
            <div id="menu-tree">
                <div>
                    <div class="json-tree-menu">
                        Menu
                        <!-- <span id="addFile" onclick="createJson();" style="background-image: url(/common/icon/add.svg);"></span>
                        <span id="editFile" onclick="editJson();" style="background-image: url(/common/icon/edit.svg);"></span>
                        <span id="deleteFile" onclick="deleteJson();" style="background-image: url(/common/icon/delete.svg);"></span>
                        <span id="downloadFile" onclick="downloadJson();" style="background-image: url(/common/icon/download.svg);"></span>
                        <span id="uploadFile" onclick="clickUploadJson();" style="background-image: url(/common/icon/upload.svg);"></span>
                        <input style="display: none;" id="uploadFileInput" type='file' accept='text/json' onchange='uploadJson(event)'>
                        <span id="copyPath" onclick="copyPath();" style="background-image: url(/common/icon/path.svg);"></span>
                        <span id="hideTree" onclick="hideTree();" style="background-image: url(/common/icon/left.svg);"></span> -->
                    </div>
                </div>
                <div id="fileDir" class="ztree"></div>
            </div>
        </div>
        <div data-options="region:'center',title:'',href:null" style="padding:0px;width:auto;height: 100%;">
            <div class="buttons">
                <button id="showAPIBtn" onclick="buttonAction.showAPI()">显示API帮助</button>
                <button id="getCodeBtn" onclick="buttonAction.getCode()">获取代码</button>
                <button id="setCodeBtn" onclick="buttonAction.setCode()">设置代码</button>
                <button id="getASTBtn" onclick="buttonAction.getAST()">获取AST</button>
                <button id="executeCodeBtn" onclick="buttonAction.executeCode()">执行代码</button>
                <button id="formatCodeBtn" onclick="buttonAction.formatCode()">格式化</button>
                <button id="getEditModeBtn" onclick="buttonAction.getEditMode()">获取编辑模式</button>
                <button id="getEditModeBtn" onclick="buttonAction.setEditMode()">设置编辑模式</button>
            </div>
            <div id="operateContainer" class="easyui-tabs" style="overflow: auto;">
            </div>
        </div>
    </div>
</div>

<!-- js -->
<script src="res/ztree.js"></script>
<script src="res/tabs.js"></script>
<script src="res/button.js"></script>

<script>
    var dslEditor = null;

    function bindDSLEditorAPI(_dslEditor) {
        dslEditor = _dslEditor;
    }

    var buttonAction = {
        getCode: function() {
            var code = dslEditor.getCode();
            alert(code);
        },
        setCode: function() {
            var code = prompt("input code:");
            dslEditor.setCode(code);
        },
        getAST: function() {
            var ast = dslEditor.getAST();
            alert(JSON.stringify(ast));
        },
        executeCode: function() {
            dslEditor.executeCode(function(jsonResult) {
                alert(JSON.stringify(jsonResult));
            });
        },
        formatCode: function() {
            dslEditor.formatCode();
        },
        getEditMode: function() {
            var mode = dslEditor.getEditMode();
            alert(mode);
        },
        setEditMode: function() {
            var mode = prompt("mode: vim or default", "vim");
            dslEditor.setEditMode(mode);
        },
        showAPI: function() {
            var help = "=========API列表=========\n\n";
            help += "1, 获取代码: string getCode()\n";
            help += "2, 设置代码: void setCode(code)\n";
            help += "3, 获取AST: json getAST()\n";
            help += "4, 执行代码: json executeCode()\n";
            help += "5, 格式化代码: void formatCode()\n";
            help += "6, 获取编辑模式: string getEditMode()  default|vim\n";
            help += "7, 设置编辑模式: void setEditMode(mode) default|vim\n";
            alert(help);
        },
    };
</script>